<include file="Public/header" />
<body>
        <div class="layui-container" style="margin-top: 20px;">
            <div class="layui-row">
                <div class="layui-col-md10">
                <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
                  <legend>修改密码</legend>
                </fieldset>
                    <form class="layui-form" >
                        <div class="layui-form-item">
                          <label class="layui-form-label">原密码</label>
                          <div class="layui-input-inline">
                            <input type="password" name="pass" required  lay-verify="required" placeholder="请输入原密码" autocomplete="off" class="layui-input" id="tpass">
                          </div>
                          <div class="layui-form-mid layui-word-aux" style="color:red;">原密码</div>
                        </div>
                         <div class="layui-form-item">
                          <label class="layui-form-label">新密码</label>
                          <div class="layui-input-inline">
                            <input type="password" name="newpass1" required  lay-verify="required" placeholder="请输入新密码" autocomplete="off" class="layui-input" id="newpass1">
                          </div>
                          <div class="layui-form-mid layui-word-aux" style="color:red;">请牢记新密码</div>
                        </div>
                         <div class="layui-form-item">
                          <label class="layui-form-label">新密码</label>
                          <div class="layui-input-inline">
                            <input type="password" name="newpass2" required  lay-verify="required" placeholder="请再次输入新密码" autocomplete="off" class="layui-input" id="newpass2">
                          </div>
                          <div class="layui-form-mid layui-word-aux" style="color:red;">新密码验证</div>
                        </div>
                        <div class="layui-form-item">
                          <div class="layui-input-block">
                          <!-- <a class="layui-btn" href="javascript:;" lay-submit onclick="sub('<{$te.tid}>')">立即提交</a> -->
                          <!-- <button class="layui-btn" lay-submit onsubmit="sub('<{$te.tid}>')">立即提交</button> -->
                            <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
                            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                          </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>  
    <script>
layui.use(['layer','element','form'], function(){
    var layer = layui.layer,element=layui.element,form=layui.form;
        form.on('submit(formDemo)', function(){
        // layer.msg(JSON.stringify(data.field));
        //alert(1);
        var pass=$('#tpass').val(),newpass1=$('#newpass1').val(),newpass2=$('#newpass2').val();
        //alert(tname);
        $.post("<{:U('check_tpass')}>",{pass:pass},function(data,status){
              //alert("Data: " + data + "\nStatus: " + status);
              if (data == 0) {
                layer.msg('您输入的原密码错误!',{icon: 5,time:2000});
                // setTimeout("x_admin_close()",1000);
                // setTimeout("window.parent.location.reload()",1000);
              } else{
                if (newpass1!=newpass2) {
                    layer.msg('您两次输入的新密码不一致!',{icon: 5,time:2000});
                } else {
                    $.post("<{:U('do_tpass')}>",{pass:newpass2},function(data1,status){
                         //alert("Data: " + data + "\nStatus: " + status);
                         //alert(data1)
                        layer.msg('修改成功！',{icon: 6,time:1000});
                        setTimeout("x_admin_close()",1000);
                    })
                    
                }
              } 
          });
        return false;
      });
});
 </script>

</body>

</html>